package com.daos;

import java.util.List;

import org.springframework.stereotype.Service;

import com.model.Activity;
import com.model.Comment;

@Service
public class CommentDao extends AbstractDao<Comment> {

	public Comment getCommentById(int id) {
		Comment comment = (Comment) hibernateTemplate.find(
				"from Comments c where c.id = ?", id).get(0);
		return comment != null ? comment : null;

	}

	@SuppressWarnings("unchecked")
	public List<Comment> getCommentsForTask(long id) {
		return hibernateTemplate.find(
				"from Comments c where c.task.id = ? order by c.date desc", id);
	}

	public List<Activity> getAllComments() {
		 return hibernateTemplate.find(
				"from Comments c  where c.task.visible = true order by c.date desc");
	}

}
